package com.example.dmdomain;

import com.example.dmdomain.entity.ElectricityPrice;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ElectricityPriceRepository extends JpaRepository<ElectricityPrice, String>, JpaSpecificationExecutor<ElectricityPrice> {

	@Query(value = "select distinct ep.city from electricity_price ep;",nativeQuery = true)
	List<String> findAllCities();

	@Query(value = "select distinct ep.electricity_category, ep.\"type\" from electricity_price ep;",nativeQuery = true)
	List<Object[]> findAllTypes();

	@Query(value = "select distinct ep.voltage from electricity_price ep ;",nativeQuery = true)
	List<String> findAllVoltages();

	@Query(value = "select distinct ep.\"year\",ep.\"month\" from electricity_price ep ;",nativeQuery = true)
	List<Object[]> findAllMonths();


	@Query(value = "SELECT ep.city,ep.electricity_category,ep.\"type\",ep.voltage,ep.consumption from electricity_price ep ;",nativeQuery = true)
	List<Object[]> findAllCityInfos();
}
